<?php
namespace Home\Controller;
use Think\Controller;

/**
 * 位置控制
 */
class IndexController extends Controller {
	/**
	 * 获取省份列表
	 */
	public function getProvince(){
		//实例化location对象
		$location = M('location_table');

		//查询省份
		$result = $location->field('province')->select();

		//ajax返回
		$resultList['result'] = $result;
		$this->ajaxReturn($resultList);
	}

	/**
	 * 获取城市列表
	 */
	public function getCity(){
		//从前端获取省份信息
		$province = $_POST['province'];

		//实例化location对象
		$location = M('location_table');

		//查询城市
		$where['province'] = $province;
		$result = $location->where($where)->field('city')->select();

		//ajax返回
		$resultList['result'] = $result;
		$this->ajaxReturn($resultList);
	}

	/**
	 * 获取取列表
	 */
	public function getDistrict(){
		//从前端获取城市信息
		$city = $_POST['city'];

		//实例化location对象
		$location = M('location_table');

		//查询区
		$where['city'] = $city;
		$result = $location->where($where)->field('district')->select();

		//ajax返回
		$resultList['result'] = $result;
		$this->ajaxReturn($resultList);
	}
}